<template>
	<div class="fenxiaoshangguanli">
    <div v-if="!shoujiban">
      <left></left>
      <div class="right">
        <div style="height: 91px; border-bottom: 1px solid rgb(227, 232, 241); width: 100%; padding: 0 30px;" class="flexbc">
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item >分销商管理</el-breadcrumb-item>
          </el-breadcrumb>
          <top></top>
        </div>

        <div style="padding: 37px 30px 0 30px; height: calc(100vh - 91px); overflow: auto;">
          <div class="flex" style="margin-bottom: 30px;">
            <div class="flexcc " style="cursor: pointer;"  @click="changestatus('0')" :class="this.search.all == '0'?'sxjact':'sxj'"  >直接分销商</div>
            <div class="flexcc " style="cursor: pointer;"  @click="changestatus('1')" :class="this.search.all == '1'?'sxjact':'sxj'">全部分销商</div>
          </div>
          <div v-if="this.search.all == '0'" class="flexc" style="font-size: 16px; font-weight: bold; margin-bottom: 20px;">
            <div><img src="../../../static/img/xitong3.png" style="width: 22px; margin-right: 10px;"></div>
            <div>发展分销商</div>
          </div>
          <div v-if="this.search.all == '0'" class="flexbc" style="height: 80px; background: rgb(255, 255, 255); border-radius: 20px; padding:0 30px;margin-bottom: 30px;">
              <div class="flex" style="align-items: center;height: 100%;">
                  <div style="color:#ACACAC;font-size:14px;width: 200px; overflow: hidden;    text-overflow:ellipsis;    white-space: nowrap;">{{ copyurl }}</div>
                  <el-button @click="copy(copyurl)" style="margin-left: 40px;height: 30px;padding: 0 15px;"  type="primary" round >复制邀请链接</el-button>
              </div>
          </div>
          <div class="flexc" style="font-size: 16px; font-weight: bold; margin-bottom: 20px;">
            <div><img src="../../../static/img/xitong3.png" style="width: 22px; margin-right: 10px;"></div>
            <div>分销商列表</div>
          </div>
          <div style="height: 112px; background: rgb(255, 255, 255); border-radius: 20px; padding: 20px;">
              <div class="flex">
                <div>
                  <div style="margin-bottom: 10px;">分销商</div>
                  <div><el-input v-model="search.name" style="width: 200px; margin-right: 30px;" placeholder="请输入"></el-input></div>
                </div>
                <div>
                  <div style="margin-bottom: 10px;">联系电话</div>
                  <div><el-input v-model="search.mobile" style="width: 200px; margin-right: 30px;" placeholder="请输入"></el-input></div>
                </div>
                <div style="margin-right: 30px;">
                  <div style="margin-bottom: 10px;">&nbsp;</div>
                  <div><el-button @click="searchbtn" type="primary" round icon="el-icon-search">检索</el-button></div>
                </div>
              </div>
          </div>

          <div style="margin-top: 20px;">
            <el-table :data="list" style="width: 100%">
              <el-table-column align="center" prop="notes_name" label="备注名">
                <template slot-scope="scope">
                  {{ scope.row.notes_name }} <i class="el-icon-edit" @click="openeditname(scope.row)" style="color: rgb(0, 90, 255); margin-left: 20px;cursor: pointer;"></i>
                </template>
              </el-table-column>
              <el-table-column align="center" prop="name" label="分销商"></el-table-column>
              <el-table-column v-if="this.search.all == '0'" align="center" prop="exp" label="等级值"></el-table-column>
              <el-table-column v-if="this.search.all == '0'" align="center" prop="level" label="等级"></el-table-column>
              <el-table-column align="center" prop="mobile" label="联系方式"></el-table-column>
              <el-table-column v-if="this.search.all == '0'" align="center" label="商品佣金比例">
                <template slot="header" slot-scope="scope">
                  <div class="flexcc">
                    <div>商品佣金比例</div>
                    <div>
                      <el-tooltip class="item" effect="dark" content="针对分销商的个性化佣金设置，所有商品都会按照设置的佣金金额乘以该比例计算佣金，例：佣金100元，如果此处设置为120%，那么最终支付佣金120元，如果设置80%最终支付80元（修改后影响新订单，已有订单仍为订单创建时的金额计算）" placement="top">
                        <i class="el-icon-question" style="color: rgb(175, 179, 188); margin-left: 20px;cursor: pointer; font-size: 25px;"></i>
                      </el-tooltip>
                    </div>
                  </div>
                </template>
                <template slot-scope="scope">
                  <div class="flexcc">
                    {{ scope.row.commission_rate }} %
                    <i v-if="search.all == '0'&&openswitch!=1" class="el-icon-edit" @click="yongjinkai(scope.row,1)" style="color: rgb(0, 90, 255); margin-left: 20px;cursor: pointer;"></i>
                  </div>
                </template>
              </el-table-column>
              <el-table-column v-if="this.search.all == '0'" align="center" label="佣金抽成比例">
                <template slot="header" slot-scope="scope">
                  <div class="flexcc">
                    <div>佣金抽成</div>
                    <div>
                      <el-tooltip class="item" effect="dark" content="针对分销商的下级发展订单的个性化抽成比例设置，按照当前商品佣金金额的百分比抽取，例：佣金100元，如果此处设置为20%，其下游每发展一个订单上游获得20元，注：分销商仅从直接发展的分销商售卖订单中抽成，不会多层级抽取。" placement="top">
                        <i class="el-icon-question" style="color: rgb(175, 179, 188); margin-left: 20px;cursor: pointer; font-size: 25px;"></i>
                      </el-tooltip>
                    </div>
                  </div>
                </template>
                <template slot-scope="scope">
                  <div class="flexcc">
                    <div v-if="scope.row.user_fee_type == 0">抽成比例：</div>
                    <div v-if="scope.row.user_fee_type == 0">{{scope.row.user_fee_percent}}%</div>

                    <div v-if="scope.row.user_fee_type == 1">抽成金额：</div>
                    <div v-if="scope.row.user_fee_type == 1">{{scope.row.user_fee_amount}}元</div>

                    <!-- {{ scope.row.user_fee_percent }} % -->
                    <i v-if="search.all == '0'&&openswitch!=1" class="el-icon-edit" @click="yongjinkai(scope.row,2)" style="color: rgb(0, 90, 255); margin-left: 20px;cursor: pointer;"></i>
                  </div>
                </template>
              </el-table-column>
              <el-table-column align="center" label="备注信息">
                <template slot-scope="scope">
                  <div class="flexcc">
                    <el-tooltip class="item" effect="dark" :content="scope.row.notes" placement="top">
                      <div class="t_over_text">
                        {{ scope.row.notes }}
                      </div>
                    </el-tooltip>
                    <i class="el-icon-edit" @click="openeditnote(scope.row)" style="color: rgb(0, 90, 255); margin-left: 20px;cursor: pointer;"></i>
                  </div>
                </template>
              </el-table-column>
              <el-table-column align="center" prop="ok_count" label="操作" width="200px">
                <template slot-scope="scope">
                  <div class="flexcc">
                    <div v-if="search.all == '0'" @click="go('/fenxiaoshangguanli/dengjiguanli',scope.row.id)" style="color: rgb(0, 90, 255); cursor: pointer; margin-right: 20px;">等级值管理</div>
                    <div v-if="search.all == '0'&&scope.row.status==0" @click="delbtn(scope.row,1)" style="color: rgb(0, 90, 255); cursor: pointer;">停用</div>
                    <div v-if="search.all == '0'&&scope.row.status==-10" @click="delbtn(scope.row,2)" style="color: #FF0202; cursor: pointer;">已停用</div>
                    <div v-if="search.all == '1'&&scope.row.freeze=='0'" @click="coldbtn(scope.row,1)" style="color: rgb(0, 90, 255); cursor: pointer;margin-left: 20px;margin-right: 20px;">冻结提单</div>
                    <div v-if="search.all == '1'&&scope.row.freeze=='1'" @click="coldbtn(scope.row,2)" style="color:#FF0000; cursor: pointer;">已冻结提单</div>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <el-pagination style="text-align: right; padding: 20px;" background layout="prev,pager,next,total,jumper" :page-size="search.page_size"
              @current-change = 'pagechange' :total="total"></el-pagination>
			  <!-- <footers></footers> -->
        </div>
      </div>
    </div>


    <!-- 修改备注名 -->
    <el-dialog
      title="修改备注名"
      :visible.sync="isshowchangenotename"
      :close-on-click-modal="false"
      width="500px">
      <el-input v-model="editnotename" placeholder="请输入备注名"></el-input>
      <div style="margin-top: 20px;text-align: center;">
        <el-button @click="isshowchangenotename = false">取 消</el-button>
        <el-button type="primary" @click="editnamebtn">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 修改备注 -->
    <el-dialog
      title="修改备注"
      :visible.sync="isshowchangenotenote"
      :close-on-click-modal="false"
      width="500px">
      <el-input v-model="editnotenote" type="textarea"
  :rows="3" placeholder="请输入备注"></el-input>
      <div style="margin-top: 20px;text-align: center;">
        <el-button @click="isshowchangenotenote = false">取 消</el-button>
        <el-button type="primary" @click="editnotebtn">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog
        :title="yjorch==1?'修改佣金比例':'修改抽成比例'"
        :visible.sync="yongjinlog"
        :close-on-click-modal="false"
        width="500px">
        <!-- 修改佣金比例 -->
        <div v-if='yjorch==1' style="position: relative;">
          <div style="position: absolute; right: 20px; top: 0; z-index: 999; line-height: 41px;">%</div>
          <el-input v-model="yongjinall.commission_rate" placeholder="请输入百分比数字,例80"></el-input>
        </div>
        <!-- 抽成种类选择 -->
        <div v-if='yjorch==2' style="margin-bottom: 20px;">
          <el-radio @input="changeradio" v-model="typeradio" :label="0">比例</el-radio>
          <el-radio @input="changeradio" v-model="typeradio" :label="1">固定值</el-radio>
        </div>
        <!-- 修改抽成金额 -->
        <div v-if='yjorch==2&&typeradio==1' style="position: relative;">
          <!-- <div style="position: absolute; right: 20px; top: 0; z-index: 999; line-height: 41px;">%</div> -->
          <el-input v-model="chouchengall.user_fee_amount" placeholder="请输入金额"></el-input>
        </div>
        <!-- 修改抽成比例 -->
        <div v-if='yjorch==2&&typeradio==0' style="position: relative;">
          <div style="position: absolute; right: 20px; top: 0; z-index: 999; line-height: 41px;">%</div>
          <el-input v-model="chouchengall.user_fee_percent" placeholder="请输入百分比数字,例80"></el-input>
        </div>

        <div style="margin-top: 20px;text-align: center;">
          <el-button @click="yongjinlog = false">取 消</el-button>
          <!-- 修改佣金比例 -->
          <el-button type="primary" v-if="yjorch==1" @click="yongjingo">确 定</el-button>
           <!-- 修改抽成比例 -->
          <el-button type="primary" v-if="yjorch==2" @click="chouchenggo">确 定</el-button>
        </div>
      </el-dialog>


      <!-- 手机版 -->

      <div v-if="shoujiban" style=" color: rgb(2, 12, 29); font-size: 0.24rem; background: #f6f8fb; padding-top: 1rem;">
        <topandleft></topandleft>
        <div style="background: #fff; padding: 0.3rem;">
          <div class="flexc" style="margin-bottom: 0.3rem;">
            <div style="width: 2px; height: 0.2rem; background: rgb(2, 12, 29); margin-right: 10px; overflow: hidden;"></div>
            <div style="font-size: 0.36rem; font-weight: bold;">分销商管理</div>
          </div>
          <div class="flexc" style="margin-bottom: 0.3rem;">
            <div style="color: rgb(175, 179, 188);">首页</div>
            <div style="margin: 0 0.2rem;color: rgb(175, 179, 188);">·</div>
            <div>分销商管理</div>
          </div>
        </div>
        <div style="padding: 0.3rem;">
          <div class="flex" style="justify-content: space-between;margin-bottom: 0.3rem;">
            <div class="flexcc " style="cursor: pointer;"  @click="changestatus('0')" :class="this.search.all == '0'?'sxjactsj':'sxjsj'"  >直接分销商</div>
            <div class="flexcc " style="cursor: pointer;"  @click="changestatus('1')" :class="this.search.all == '1'?'sxjactsj':'sxjsj'">全部分销商</div>
          </div>
          <div class="flexc" style=" margin-bottom: 0.2rem; font-size: 0.34rem; font-weight: 400;">
            <div><img src="../../../static/img/xitong3.png" style="width: 0.4rem; margin-right: 0.1rem;"></div>
            <div>发展分销商</div>
          </div>
          <div class="flexbc">
            <div style="width: 100%; background: rgb(255, 255, 255); border-radius: 0.2rem; padding: 0.2rem;" class="flexc" @click="copy(copyurl)">
              <div style="padding: 0 0.2rem; overflow: hidden;">
                <div style="color: rgb(175, 179, 188); margin-bottom: 0.1rem; ">{{copyurl}}</div>
                <div style="cursor: pointer; text-align: center; margin: 0.2rem auto 0; background: rgb(0, 90, 255); line-height: 0.6rem; border-radius: 0.3rem; width: 2rem; color: #fff;">复制邀请链接</div>
              </div>
            </div>
          </div>

          <div class="flexc" style=" margin-bottom: 0.2rem; margin-top: 0.4rem; font-size: 0.34rem; font-weight: 400;">
            <div><img src="../../../static/img/xitong3.png" style="width: 0.4rem; margin-right: 0.1rem;"></div>
            <div>分销商列表</div>
          </div>

          <div style=" background: rgb(255, 255, 255); border-radius: 0.2rem; padding: 0.2rem;  margin-bottom: 0.3rem;" >
              <div style="margin-bottom: 0.2rem;"><el-input v-model="search.selling_point" style="width: 100%;" placeholder="请输入分销商"></el-input></div>
              <div class="flex"  style="margin-bottom: 0.3rem;">
                <div style="flex-grow: 1;"><el-input v-model="search.selling_point" style="width: 100%;" placeholder="请输入商品名称"></el-input></div>
                <div @click="searchbtn" class="flexcc" style="background: rgb(0, 90, 255); height: 41px; border-radius: 41px; padding: 0 0.4rem; color: #fff;">检索</div>
              </div>
          </div>

          <div style="background: #fff; border-radius: 0.3rem; padding: 0.3rem; margin-top: 0.2rem;" v-for="item in list" :key="item.id">
            <div class="flexbc" style="margin-bottom: 0.2rem;">
              <div style="color: rgb(120, 125, 133);">备注名</div>
              <div>{{item.notes_name}}<i class="el-icon-edit" @click="openeditname(item)" style="color: rgb(0, 90, 255); margin-left: 20px;cursor: pointer;"></i></div>
            </div>
            <div class="flexbc" style="margin-bottom: 0.2rem;">
              <div style="color: rgb(120, 125, 133);">分销商</div>
              <div>{{item.name}}</div>
            </div>
            <div class="flexbc" style="margin-bottom: 0.2rem;">
              <div style="color: rgb(120, 125, 133);">联系电话</div>
              <div>{{item.mobile}}</div>
            </div>
            <div class="flexbc" style="margin-bottom: 0.2rem;">
              <div v-if="item.user_fee_type == 0" style="color: rgb(120, 125, 133);">抽成比例</div>
              <div v-if="item.user_fee_type == 0">{{item.user_fee_percent}}%</div>

              <div v-if="item.user_fee_type == 1" style="color: rgb(120, 125, 133);">抽成金额</div>
              <div v-if="item.user_fee_type == 1">{{item.user_fee_amount}}元</div>
              <!-- <div style="color: rgb(120, 125, 133);">商品佣金比例</div>
              <div>
                {{ item.commission_rate }} %
                <i class="el-icon-edit" @click="yongjinkai(item)" style="color: rgb(0, 90, 255); margin-left: 20px;cursor: pointer;"></i>
              </div> -->
            </div>
            <!-- <div class="flexbc">
              <div>佣金抽成比例</div>
              <div><i class="el-icon-edit" @click="openeditname(item)" style="color: rgb(0, 90, 255); margin-left: 20px;cursor: pointer;"></i></div>
            </div> -->
            <div class="flexbc" style="margin-bottom: 0.2rem;">
              <div style="color: rgb(120, 125, 133);">备注信息</div>
              <div>
                {{item.notes}}
                <i class="el-icon-edit" @click="openeditnote(item)" style="color: rgb(0, 90, 255); margin-left: 20px;cursor: pointer;"></i>
              </div>
            </div>
            <div class="flexbc">
              <div style="color: rgb(120, 125, 133);">操作</div>
              <div class="flexcc">
                <!-- <div @click="go('/fenxiaoshangguanli/dengjiguanli',item.id)" style="color: rgb(0, 90, 255); cursor: pointer; margin-right: 20px;">等级值管理</div> -->
                <div v-if="search.all == '0'&&scope.row.status==0" @click="delbtn(item,1)" style="color: rgb(0, 90, 255); cursor: pointer;">停用</div>
                <div v-if="search.all == '0'&&scope.row.status==-10" @click="delbtn(item,2)" style="color: rgb(0, 90, 255); cursor: pointer;">已停用</div>
                <div v-if="search.all == '1'&&item.freeze=='0'" @click="coldbtn(item,1)" style="color: rgb(0, 90, 255); cursor: pointer;margin-left: 20px;margin-right: 20px;">冻结提单</div>
                <div v-if="search.all == '1'&&item.freeze=='1'" @click="coldbtn(item,2)" style="color:#FF0000; cursor: pointer;">已冻结提单</div>
              </div>
            </div>

          </div>

        </div>
      </div>
      <!-- 冻结弹窗 -->
      <el-dialog
        :title="coldtype==1?'冻结提单':'取消冻结提单'"
        :visible.sync="isshowcold"
        width="500px"
        :close-on-click-modal="false"	>
        <div v-if="coldtype==1">
          冻结提单后，该分销商的订单将不会被生产，直到您解除冻结
        </div>
        <div v-if="coldtype==2">
          取消冻结提单后，该分销商订单会重新流转，确定取消冻结么？
        </div>
        <div style="text-align:right;margin-top:20px">
          <el-button round @click="isshowcold = false">取 消</el-button>
          <el-button round type="primary" @click="surecold">确 定</el-button>
        </div>
      </el-dialog>
	</div>
</template>

<script>
  import left from '../left.vue'
  import top from '../top.vue'
  import footers from '../footer.vue'
  import topandleft from '../topandleft.vue'
	export default {
		name: 'fenxiaoshangguanli',
    components:{
      left,top,topandleft,footers
    },
		data() {
			return {
        search:{
          page:1,
          page_size:20,
          name:'',
          mobile:'',
          all:'0'
        },
        total:0,
        list:[],
        isshowchangenotename:false,
        editnotename:'',
        itemnotename:{},
        isshowchangenotenote:false,
        editnotenote:'',
        copyurl:'',
        yongjinlog:false,
        yongjinall:"",
        shoujiban:false,

        yaoqing:{
          yaoqingma:123
        },
        yjorch:'',
        chouchengall:'',
        shoujiban:false,
        coldtype:'',
        coldrow:{},
        isshowcold:false,
        typeradio:1,
        openswitch:null
			}
		},
		created() {
      //列表

      //获取邀请链接
      this.getsharelink()
      this.getinfo()
		},
		mounted() {
      if(window.screen.width < 1080){
        this.shoujiban = true
        var h = document.documentElement.clientWidth / 7.5 + 'px';
        document.documentElement.style.fontSize = h;
        this.search.page_size = 200
      }

      this.getlist()
		},
		methods: {
      yongjinkai:function(item,type){
        this.yjorch = type
        if(type==1){
          //商品佣金比例
          this.yongjinall={
            id:item.id,
            commission_rate:item.commission_rate
          }
        }
        if(type==2){
          this.typeradio = item.user_fee_type
          this.chouchengall={
              id:item.id,
              user_fee_amount:item.user_fee_amount,
              user_fee_percent:item.user_fee_percent,
              user_fee_type:item.user_fee_type
            }
          // if(item.user_fee_type==1){
          //   //佣金抽成固定值
          //   this.chouchengall={
          //     id:item.id,
          //     user_fee_amount:item.user_fee_amount,
          //     user_fee_type:1
          //   }
          // }else{
          //   //佣金抽成比例
          //   this.chouchengall={
          //     id:item.id,
          //     user_fee_percent:item.user_fee_percent,
          //     user_fee_type:0
          //   }
          // }

        }

        this.yongjinlog = true
      },
      yongjingo:function(){
        var regu = /^(?!-)\d{1,3}$/;
        var re = new RegExp(regu);
        if (re.test(this.yongjinall.commission_rate)) {

          axios.post('/own/agent/useruser/update',{id:this.yongjinall.id,commission_rate:this.yongjinall.commission_rate *1}).then((response)=>{
          	if (response.data.msg.code == 0) {
              this.getlist()
              this.yongjinlog = false
          	} else {
          		this.$message.error(response.data.msg.info);
          	}
          })
        }else{
          this.$message.error('佣金比例不符合规则');
          return false;
        }
      },
      chouchenggo:function(){
        if(this.chouchengall.user_fee_type==1){
          //固定值
          axios.post('/own/agent/useruser/update',{id:this.chouchengall.id,user_fee_amount:this.chouchengall.user_fee_amount*1,user_fee_type:this.chouchengall.user_fee_type }).then((response)=>{
              if (response.data.msg.code == 0) {
                this.getlist()
                this.yongjinlog = false
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
        }else{
          //比例
          var regu = /^\d{1,3}$/;
          var re = new RegExp(regu);
          if (re.test(this.chouchengall.user_fee_percent)) {

            axios.post('/own/agent/useruser/update',{id:this.chouchengall.id,user_fee_percent:this.chouchengall.user_fee_percent*1,user_fee_type:this.chouchengall.user_fee_type }).then((response)=>{
              if (response.data.msg.code == 0) {
                this.getlist()
                this.yongjinlog = false
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
          }else{
            this.$message.error('抽成比例不符合规则，只接受正数和整数且百分比不得超过3位数');
            return false;
          }
        }

      },
      //列表
      getlist(){
        axios.get('/own/agent/list',{params:this.search}).then((response)=>{
        	if (response.data.msg.code == 0) {

            if(response.data.data.data.length > 0){
              response.data.data.data.forEach(item=>{
                item.commission_rate = parseInt(item.commission_rate)
              })
            }

            this.list = response.data.data.data
            this.total = response.data.data.total

        	} else {
        		this.$message.error(response.data.msg.info);
        	}
        })
      },
      //分页
      pagechange(val){
        console.log(val)
        this.search.page = val
        //列表
        this.getlist()
      },
      //搜索
      searchbtn(){
        this.search.page = 1
        this.getlist()
      },
      //删除
      delbtn(item,type){

        if(type==1){
          //停用
          this.$confirm('停用后，该分销商账户将不能登录，直到您解除停用', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            axios.post('/own/agent/delete',{
              user_id:item.id,
              status:-10
            }).then((response)=>{
              if (response.data.msg.code == 0) {
                this.$message({
                  type: 'success',
                  message: '操作成功!'
                });
                this.getlist()
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消'
            });
          });
        }else if(type==2){
          //开启
          this.$confirm('取消停用后，该分销商账户将可以登录，确认取消停用么？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            axios.post('/own/agent/delete',{
              user_id:item.id,
              status:0
            }).then((response)=>{
              if (response.data.msg.code == 0) {
                this.$message({
                  type: 'success',
                  message: '操作成功!'
                });
                this.getlist()
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消'
            });
          });
        }



      },
      //打开修改备注名
      openeditname(item){
        this.isshowchangenotename = true
        this.editnotename = item.notes_name
        this.itemnotename = item
      },
      //提交修改备注名
      editnamebtn(){
        axios.post('/own/agent/notes-name/set',{
            user_id:this.itemnotename.id,
            notes_name:this.editnotename
          }).then((response)=>{
            if (response.data.msg.code == 0) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              });
              this.isshowchangenotename = false
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
       //打开修改备注
       openeditnote(item){
        this.isshowchangenotenote = true
        this.editnotenote = item.notes
        this.itemnotename = item
      },
      //提交修改备注
      editnotebtn(){
        axios.post('/own/agent/notes/set',{
            user_id:this.itemnotename.id,
            notes:this.editnotenote
          }).then((response)=>{
            if (response.data.msg.code == 0) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              });
              this.isshowchangenotenote = false
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      //复制功能
			copy: function(t) {
        console.log(t)
        t = t.toString()
				var that = this;
				this.$copyText(t).then(res => {
					that.$message.success("复制成功");
				});
			},
      //获取邀请链接
      getsharelink(){
        //获取当前链接

        axios.get('/own/reseller/check-code').then((response)=>{
        	if (response.data.msg.code == 0) {

            console.log('当前链接')
            this.copyurl = window.origin+'/hou/login?'+encodeURIComponent(response.data.data);

        	} else {
        		this.$message.error(response.data.msg.info);
        	}
        })
      },
      //冻结提单
      coldbtn(row,type){
        this.coldrow = row
        this.coldtype = type
        this.isshowcold = true
      },
      surecold(){
        if(this.coldtype==1){
          //冻结
          axios.post('/own/user/freeze',{
            id:this.coldrow.id,
            freeze:'1'
          }).then((response)=>{
            if (response.data.msg.code == 0) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              });
              this.isshowcold = false
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })

        }
        if(this.coldtype==2){
          //取消冻结
          axios.post('/own/user/freeze',{
            id:this.coldrow.id,
            freeze:'0'
          }).then((response)=>{
            if (response.data.msg.code == 0) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              });
              this.isshowcold = false
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
        }
      },
      //tab切换
      changestatus(val){
        this.search.all = val
        this.search.page = 1
        this.getlist()

      },
      //切换种类
      changeradio(){
        console.log(this.typeradio)
        this.chouchengall.user_fee_type = this.typeradio
      },
      getinfo:function(){
          axios.get('/own/system/get').then((response)=>{
          	if (response.data.msg.code == 0) {
              this.openswitch = response.data.data.level_open
          	} else {
          		this.$message.error(response.data.msg.info);
          	}
          })
      },
		}
	}
</script>


<style scoped >
 .t_over_text{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: calc(100% - 40px);
 }
 .t_tab_box{
  display: flex;

 }
 .t_tab{
  width: 188px;
  height: 60px;
  text-align: center;
  line-height: 60px;
  border-radius: 30px;
  color:white;
  font-size: 24px;
  margin-right: 28px;
 }

.sxj{background: rgb(227, 232, 241); border-radius:30px; font-size: 24px; text-align: center; font-weight: 500; color: rgb(175, 179, 188); width: 190px; height: 60px; margin-right: 30px; }
.sxjact{background: rgb(0, 90, 255); border-radius:30px; font-size: 24px; text-align: center; font-weight: 500; color: rgb(255, 255, 255); width: 190px; height: 60px; margin-right: 30px; }

.sxjactsj{background: rgb(0, 90, 255); border-radius:0.3rem; text-align: center; font-weight: 500; color: rgb(255, 255, 255); width: 3.3rem; height: 0.7rem;  }
.sxjsj{background: rgb(227, 232, 241); border-radius:0.3rem;  text-align: center; font-weight: 500; color: rgb(175, 179, 188); width: 3.3rem; height: 0.7rem; }
</style>
